home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.10 Oct 93 / Fixed-Point Math / matrix.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-23  |  631 b   |  28 lines  |  [TEXT/KAHL]

  1. /***************************************
  2. * matrix.h
  3. * matrix template class interface
  4. ***************************************/
  5.  
  6. #pragma once
  7.  
  8. #include <iostream.h>
  9. #include <assert.h>
  10.  
  11. template <class Number>
  12. class matrix {
  13. private:
  14.     Number m[4][4];
  15.     friend ostream& operator<<(ostream&, const matrix<Number>&);
  16. public:
  17.     matrix();
  18.     inline Number& operator()(const int,const int); // for matrix indexing 
  19.     matrix<Number> operator*(const matrix<Number>);
  20. };
  21.  
  22. template <class Number>
  23. inline Number& matrix<Number>::operator()(const int row, const int col)
  24. {
  25.     assert(row >=0 && row <= 3 && col >=0 && col <= 3);
  26.     return m[row][col];
  27. }
  28.